Skip to content

Conversation

seisman
Copy link
Member

@seisman seisman commented Apr 23, 2025

If files have suffixes like .json/.geojson (case insensitive), they will be converted to OGR_GMT format internally before reading.

Closes #4599.

@@ -5217,8 +5217,9 @@ FILE * gmt_fopen (struct GMT_CTRL *GMT, const char *filename, const char *mode)
if (!fd) { /* No, was not a netCDF file */
if ((c = gmt_getdatapath (GMT, &filename[first], path, R_OK)) != NULL) { /* Got the file path */
char *ext = gmt_get_ext (c); /* Get pointer to extension (or NULL if no extension) */
if (ext && mode[0] == 'r' && !strncmp (ext, "shp", 3U)) { /* Got a shapefile for reading */
/* We will do a system call to ogr2ogr in order to read the shapefile */
if (ext && mode[0] == 'r' && (!strncasecmp (ext, "shp", 3U) || !strncasecmp(ext, "geojson", 7U) || !strncasecmp(ext, "json", 4U) )) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also changed strncmp to strncasecmp so that extensions like SHP are also supported.

@seisman seisman added new feature PR that implements a new feature or capability in GMT need-review labels Apr 23, 2025
@seisman seisman added this to the 6.6.0 milestone Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-review new feature PR that implements a new feature or capability in GMT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support plotting OGR GeoJSON files
2 participants