Plotting specific part of a geographic area

Thanks for your help and its awesome. I will try it to be familiar with this.

The error or warning message of ogr2ogr is;

Warning 1: The output driver does not seem to natively support Integer64 type for field ID_0.
Converting it to Real instead. -mapFieldType can be used to control field type conversion.

Showing this warning, but it can do the work, so probably there is no problem with this warning.

To be fair, I have to mention that I have little experience working with ogr2ogr. I normally read shp files into a geopandas.Dataframe (also done here). Then it is quite easy to explore the data regarding the names and data types of the different columns:

import geopandas as gpd

shp_file = "JPN_adm1.shp"
areas = gpd.read_file(shp_file)
areas.columns
# areas.ID_1
Out[2]: 
Index(['ID_0', 'ISO', 'NAME_0', 'ID_1', 'NAME_1', 'TYPE_1', 'ENGTYPE_1',
       'NL_NAME_1', 'VARNAME_1', 'geometry'],
      dtype='object')

Thanks. I think these orgr2ogr warning not causing major problem and the task is done.

Apart from this, there is a query related to same area, I am plotting the same location area. Purpose is to plot only the Japan without surrounding areas. The code and figure are;

Proj="-JM8c"
Region="-R128/148/28/48"
gmt begin
gmt figure Japan_map png
gmt psbasemap $Proj $Region -Bxa2 -Bya2 -BWESN 
gmt pscoast $Proj $Region -W0.8p -Dh -N1 -A500 
gmt coast -EJP+C
gmt coast -Q
gmt end

To plot only this area, the clip commands (gmt coast -EJP+C, gmt coast -Q) used but it plot surrounding areas also (indicated by red arrows).

Is there a way by which surrounding areas can be removed from plot and only interest region to be plotted on map? Thanks

Is this ok?

Proj="-JM8c"
Region="-R128/148/28/48"
gmt begin
    gmt figure Japan_map png
    gmt basemap $Proj $Region -Bxa2 -Bya2 -BWESN 
    gmt coast -EJP+p
gmt end

This is awesome and thanks …

@Esteban82

There is a query related to above post, maybe you have an idea about it.

If user have some parameter data available in global shape data set, is it possible to get particular country shape data from this whole global data set?

Yes, it is possible to use gmt info to get the geographyc region of a file like csv or shp. You could also use DCW-Collections besides the iso codes.

Maybe telling us what you want to do would be more efficient.

Purpose to extract country specific parameter data from global data of that parameter, the global data in shape format. e.g. below is global plates data. I want to extract plate details which passess through specific region e.g. Japan from global plate data.

Global plates data:
Tectonic_Plate_Boundaries.zip (48.2 KB)

Global plates map:
Map

Is it possible to extract specific country plate data from above global plate shape data maybe based on country (long/lat or country boundary)?

Still not clear what you want. What specific country plate data? The plate(s) at which a country belongs?
BTW, your zip file is incomplete. A shape file is set of files, not only the .shp

Anyway, my general advise to these type of operations within the GMT family is, use GMT.jl. It has handy OGR formats reading, wrappers to GEOS functions (in case you need to do polygon intersections), etc.

I have extracted shape data for particular region from global shape data using ogr2ogr and then plotted it.

code:

gmt begin
gmt figure Test_map png
gmt coast -R130/140/30/40 -Dh -Baf -W2p -A50000 -N1 -Glightgrey -Slightblue
gmt plot Test_data.gmt -W0.5,red
gmt end

figure:

The desired output is possible but Is there a way to remove, clip or mask all red lines which plotted outside the region boundary (solid black line)?

From `coast`` manual.

Description

Plots grayshaded, colored, or textured land-masses [or water-masses] on maps and [optionally] draws coastlines, rivers, and political boundaries. Alternatively, it can (1) issue clip paths that will contain all land or all water areas, …

Hmm, maybe it would be a strategically good thing to add the administrative boundaries of Japan to DCW…

I think anyone can take the labor to add more data to DCW.

And when will we stop adding administrative borders? When the DCW has 1GB? All countries have administrative borders, and of several orders. I’ve said that before. IMO it’s not a GMT role to provide this type of data.

Absolutely, I agree.
But what if I do it - for free?

Probably better to build a plugin package from GADM. Cannot recall if polygons though, or a mix. Check out Norway and see what you get.

GADM is all about polygons
https://www.generic-mapping-tools.org/GMTjl_doc/examples/misc/gadm/#gadm

but it also says.

The data are freely available for academic use and other non-commercial use. Redistribution, or commercial use is not allowed without prior permission. See the license for more details.

We would have to seek prior permission, before spending any effort on it. But, there is no permission needed for us to write a gad-gmt repo that takes their data set and builds a gmt DCW-like compressed nc file and then GMT users could build their own gmt-compatible gadm dataset, i.e., no redistribution. We may have to do the same regarding GSHHG3 that basically builds from an OSM dataset.

I like this because we won’t have to update the dataset.