# Overlay shapefile with 3D perspective image?

**URL:** <https://forum.generic-mapping-tools.org/t/overlay-shapefile-with-3d-perspective-image/2135>\
**Category:** PyGMT Q&A\
**Created:** [September 26, 2021, 6:50pm UTC](https://forum.generic-mapping-tools.org/t/overlay-shapefile-with-3d-perspective-image/2135 "2021-09-26T18:50:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Truyenpt](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@Truyenpt](https://forum.generic-mapping-tools.org/u/Truyenpt)\
**Post date:** [September 26, 2021, 6:50pm UTC](https://forum.generic-mapping-tools.org/t/overlay-shapefile-with-3d-perspective-image/2135/1 "2021-09-26T18:50:56Z")

</div>

Hi, I am just trying to overlay shapefile to 3D perspective image but it doesn’t stick to each other. Please help me to solve this issue. Many thanks!

cshp= os.path.join(“shape”,“counties.shp”)  
fig.grdview(  
grid=grid,  
region=[minlon, maxlon, minlat, maxlat, -6000, 4000],  
perspective=[150, 30],  
frame=frame,  
projection=“M15c”,  
zsize= “4c”,  
surftype=“i”,  
plane=“-6000+gazure”,  
)

fig.plot(  
perspective=True,  
region=[minlon, maxlon, minlat, maxlat],  
data = cshp,  
)

 ![topo-plot_3d](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/0/09848d4540c49709b799245b7f92a1f7dd5ecda2.png)

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [September 26, 2021, 7:11pm UTC](https://forum.generic-mapping-tools.org/t/overlay-shapefile-with-3d-perspective-image/2135/2 "2021-09-26T19:11:59Z")

</div>

Two things.

- The second command, the plot, must use the same `region` and `zsize` than the first.
- the `cshp` array must have `lon lat elevation`, which it probably has not. In that case you must run it through `grdtrack` to get the third dimension.

---

<div class="post-metadata">

**Author:** ![Truyenpt](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@Truyenpt](https://forum.generic-mapping-tools.org/u/Truyenpt)\
**Post date:** [September 26, 2021, 7:50pm UTC](https://forum.generic-mapping-tools.org/t/overlay-shapefile-with-3d-perspective-image/2135/3 "2021-09-26T19:50:21Z")

</div>

Thank you for your swift reply.  
1- The region is the same.  
2- cshp is a list of polygons with the shapefile format. That means I need to convert the polygons to points and then use grdtrack to solve this. Do you know any other option?

 ![counties](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/5/5993c338483877eda05c1c3624d26014689332f9.png)

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [September 26, 2021, 8:00pm UTC](https://forum.generic-mapping-tools.org/t/overlay-shapefile-with-3d-perspective-image/2135/4 "2021-09-26T20:00:07Z")

</div>

> [@Truyenpt](#):
>
> The region is the same.

No it’s not, in grdimage you also have zmin/zmax but I missed to say that you need to use plot3d and not plot.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [September 26, 2021, 9:39pm UTC](https://forum.generic-mapping-tools.org/t/overlay-shapefile-with-3d-perspective-image/2135/5 "2021-09-26T21:39:14Z")

</div>

And regarding the shapefile data. Sorry, there is no escape, if data has no _z_ no draping on topography is possible.

---

<div class="post-metadata">

**Author:** ![Truyenpt](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@Truyenpt](https://forum.generic-mapping-tools.org/u/Truyenpt)\
**Post date:** [September 27, 2021, 1:41am UTC](https://forum.generic-mapping-tools.org/t/overlay-shapefile-with-3d-perspective-image/2135/6 "2021-09-27T01:41:17Z")

</div>

Hi Joaquim:

Thank you for the information. I just thought we still overlay the shapefile layer at the elevation = “0”. It is almost fit to each other when I tried to use the command:  
fig.shift\_origin(xshift=“0.1c”,yshift=“2.05c”).  
I will extract the polygons to points and then stick it through the grdtrack.

---

<div class="post-metadata">

**Author:** ![alejobeap](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@alejobeap](https://forum.generic-mapping-tools.org/u/alejobeap)\
**Post date:** [July 26, 2022, 2:50pm UTC](https://forum.generic-mapping-tools.org/t/overlay-shapefile-with-3d-perspective-image/2135/7 "2022-07-26T14:50:44Z")

</div>

Dear  
How did you solve it because I transformed to points but I get the error that I have defierent size. How can I do with the shape ?

 ![image](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/f/f517d1c7d0ce03132d04af6cc52fbcbb56713a4c.jpeg)

Thanks  
Alejandro
