示例代码:文章来源:https://www.toymoban.com/news/detail-485163.html
const char* wkt = "MultiPolygon(((12629713.75288644060492516 3896945.87303787842392921,13393072.26469473727047443 3171335.85906625585630536, 13481152.09298031032085419 3884363.0404256540350616, 12629713.75288644060492516 3896945.87303787842392921)))";
// cast because OGR_G_CreateFromWkt will move the pointer
char* pszWkt = (char*)wkt;
OGRSpatialReferenceH ref = OSRNewSpatialReference(NULL);
OGRGeometryH new_geom;
OSRSetAxisMappingStrategy(ref, OAMS_TRADITIONAL_GIS_ORDER);
OGRErr err = OGR_G_CreateFromWkt(&pszWkt, ref, &new_geom);
char* strWkt = NULL;
((OGRGeometry*)new_geom)->exportToWkt(&strWkt);
结果:文章来源地址https://www.toymoban.com/news/detail-485163.html
"MultiPolygon(((12629713.75288644060492516 3896945.87303787842392921,13393072.26469473727047443 3171335.85906625585630536, 13481152.09298031032085419 3884363.0404256540350616, 12629713.75288644060492516 3896945.87303787842392921)))"
到了这里,关于gdal创建wkt几何对象的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!