问题
How can I find out the coordinates of an svg? I have an Adobe Illustrator file that contains a map, this has been drawn and separated into US states, how can I find the coordinates of each state?
I'm just using the US map as an example, I'm going to potentially use this technique for several other maps (much more local!!).
回答1:
SVG have an XML structure. The states will be in <path>
tags, hopefully with the name of the state somewhere as an attribute. The coordinates of a path are defined by the d
attribute, but they can get quite complex as they can be relative or absolute and have various types of curves. With curves, it's probably simplest to consider just the final two values, which is where the curve ends.
For full details, see: http://www.w3.org/TR/SVG/paths.html#PathDataGeneralInformation
The situation may be more complex if further transforms are applied to the paths. Good luck!
回答2:
Inkscape does that beautifully.
inkscape -z -S some_file.svg
will output a comma-separated fields with element id and its top, left, height, width - one for each element of the SVG - like this one:
image140,266.97217,468.38721,160.90056,90.506569
g142,437.1913,468.38721,160.90056,90.506569
g144,437.1913,468.38721,160.90056,90.506569
来源:https://stackoverflow.com/questions/6953466/how-to-get-coordinates-of-an-svg