How do I convert a polygon layer to a point layer?

Question:  In Cartographica, is there a convenient way to convert a polygon layer to a point layer by centroid coordinates?

Answer: There is no in-built function. There are, however, two ways to do it without much difficulty. One would be to add the centroid coordinates to the layer and then export and import that layer as a table, using the centroid coordinates as the new coordinates. The other would be to have a small script which used the internal functions to create a clone of the current data set at the centroids of the polygons.

To use export and import, do the following:

  1. Back up your original data (especially if you don't want the centroids added to your data set) 
  2. Select the polygon layer in the Layer Stack 
  3. Choose Tools > Add Centroid Coordinates Columns
  4. Choose File > Export Table Data… 
  5. Choose File > Import Table Data…
  6. When presented with the import window, choose Coordinates as the import type, choose New Layer to import to a newly created layer, and click Import 
  7. If necessary, set the Projection for the layer using Layer > Set Layer's Projection** to match the map projection at the time of export.

Alternatively, I've attached an AppleScript script that will prompt for a layer name and do the conversion entirely within Cartographica. For some datasets it takes a little longer because of certain delays in AppleScript, but it cuts down on the amount of interaction. To run the script:
  1. Download the script 
  2. Have Cartographica running with your document running and frontmost 
  3. Double-click on the script 
  4. In the box that comes up, choose a layer for the centroids to be created from and click OK

Once you've done this, a layer will be created, the features will be added at the centroids and all of the data from the original layer will be copied over. Finally the CRS will be automatically set to the then-active Map Projection.

NOTE:  that if you want the coordinate system to be something other than the current map's coordinate system, you'll need to choose Map > Project Map… before you perform either of these two functions, as the centroid function always works in the then-current map coordinate reference system.

Have more questions? Submit a request


Powered by Zendesk