Reprojection of a shapefile

Hello @george

I don’t know that either is ‘better tested’, except to say that the Shapefile.Reproject is certainly used more than the other, since it is used internally anytime a layer requires reprojection.

There are a number of Utility functions that perform the same functions as are built in to the Shape or Shapefile classes. Another example is Shape.InterpolatePoint and Utils.LineInterpolatePoint. The utility functions might be used when you’re working ‘outside’ of the OCX, if that makes sense, while if you’re working within the OCX, and you have a Shape or Shapefile reference, you can just use the built-in function rather than calling the ‘external’ function.

You cannot necessarily assume that the current projection of the Shapefile is the same as that of the PRJ, since the Shapefile may have been reprojected when it got loaded into the map. So the Reproject of the Shapefile always takes it from ‘whatever it as at the moment’ to whatever projection you specify.

The strange thing about the Utility function, that I haven’t quite figured out, is that you provide both a ‘source’ and ‘target’ projection, which seems to ignore the ‘current’ projection of the Shapefile. It would seem to me that this could provide an unexpected result.

I would generally recommend using the Shapefile.Reproject. Keep in mind that there is also a ReprojectInPlace function, if you want to effectively assign the result right back into your source Shapefile.

Regards,
Jerry.

1 Like