Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geo Item X Y example #10

Open
kk12837 opened this issue Oct 22, 2019 · 2 comments
Open

Geo Item X Y example #10

kk12837 opened this issue Oct 22, 2019 · 2 comments

Comments

@kk12837
Copy link

kk12837 commented Oct 22, 2019

Hi

Can anyone provide an example of X Y in GeoItem.

I am not sure how to implement it, Attached with a china map.

Thanks

Keith
map2.svg.txt

@RodeoAdrian
Copy link

Hey, same question. Is someone maintaining this repo? I don't know how to get X and Y values. I only have Lat and Long from Google maps

@kitpaddle
Copy link

Alright, I'll leave a comment here explaining a few things as I had a few issues getting this (awesome) little converter to work. If like me you're not quite skilled (or patient) enough to adapt the code to your needs, or append the SVG file with the Geo Metadata, here is how you can do it with relatively simple tools:

First I recommend using INKSCAPE to edit/prepare your SVG file.

  • In Inkscape, open your SVG file and make sure your "document properties" dimension are set to PIXELS (and not mm or any other dimension). By default in Inkscape, the Y axis of the document will be 0 at the top and a higher value at the bottom. For this converter to work, it must be the opposite. So ROTATE the document by 180 degrees. Now of course, you'll probably have to rotate your drawings 180 degrees as well so they face the right way up. But make sure you rotate the drawings and keep the document 180 degrees rotated.
  • So now your Y=0 and X=0 should be at the bottom right of your document. And your drawing should be positioned on the document so the north is pointing straight up.
  • Next make a note of what the X and Y pixel coordinates are for the upper left corner (should be the dimension in pixel of your document)

Now save your document. This should be an .svg file wherever you saved it. We will now have to edit that and add the geodata.

  • Open your .svg file with Notepad. Copy the entire content and paste it into an online XML editor (I recommend: https://codebeautify.org/online-xml-editor) Then in the online editor, just before the "<defs" part, paste the whole MetaInfo part. That is the following:

Then just save the file.

  • Now go to: https://mygeodata.cloud/converter/svg-to-geojson There upload the file. If you've done the above right. It should work. If it says it cannot find any spatial data, then the pasting of the geodata in the svg file didn't go right. Because in the code the parser that is looking for the data is very finnicky so if the geodata (metainfo) wasn't added in the exact way (might be missing a tab or space or an enter or newline) the it won't work. I took my quite a few tries and its why I do this in the online XML editor I linked above as it seems to maintain correct format. I litteraly paste in the file text, go to <defs, press enter just in front of it, and then paste in the MetaInfo Geodata above.

  • Now for the last part, you need to change the actual data in the geodata. The X and Y should be the pixel coordinates for your bottom right and your top-left corners of the documents respectively. (so one should be X=0 and Y=0 and the other X=width and Y=height of your document, In pixels! (caution in Inkscape this can be mm or inches or other stuff, it should be pixels!)

  • And then add the corresponding Longitudes and Latitudes ( i just went to Google Maps, checked the most exact points I cold find corresponding and clicked them to get the coordinates, this worked fine).

  • Enter these number into the metainfo data in your svg file (easiest is through notepad). Save the file. And use it in the converter! TADAA That should be it!

Last comment, keep in mind that if you have complex shapes in your svg they might be converted to geojson but might no actually work in a geojson viewer because, as said in the readme, multipolygons and other complex paths cannot be handled by the converter at the moment. (It will "convert" them but the geojson won't actually work correctly). For simple polygons and lines it works fine =)

Hope this helps someone who has gotten stuck here! Good luck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants