The python script mapper generates SVG with irregular lat / long coordinates

I modified this question to reflect some progress in detecting a problem. I am using the following python code to create continental USA SVG. The form file does not matter, because the problem I am describing is happening no matter which shapefile I am using. The script is really simple. I basically just take the shapefile for the USA and use the bounding box to exclude Hawaii and Alaska.

from kartograph import Kartograph K = Kartograph() blah={ "layers": [ { "id":"mylayer", "src":"/Users/austinc/Documents/shapefiles/states_21basic/states.shp", } ], "bounds":{ "mode":"bbox", "data":[-130,25,-65,50], }, "proj":{ "id":"mercator" } } K.generate(blah,outfile='/Users/austinc/Desktop/mymap.svg') 

The problem is that the svg generated by this code has the wrong coordinates associated with it. When I use javascript to try to match the points on it, the points appear at the correct latitude, but are turned off by about 100 degrees longitude.

When I use the pre-prepared SVG from Kartograph, I do not have this problem (I have not tried to trim Alaska and Hawaii yet). So something about my python script calls this, but I don't understand what.

FIXED: the comment below made me think that maybe this has something to do with projection. I removed the part of the python script that draws the graph as a projection of the Mercator, and that fixes everything. I'm not sure I understand why, but if you have a similar problem and find this question: try changing the projection or not using the projection at all.

+6
source share
1 answer

Perhaps the coordinate system used in your SVG file does not match latitudes and longitudes. Perhaps you need to know which projection was used to generate the SVG file, as well as calculating latitudes and longitudes using the inverse of this projection. Perhaps try also to find out if the same problem occurs with the ready-to-use maps provided by the Cartographer.

+1
source

Source: https://habr.com/ru/post/958263/


All Articles