Could you indicate the shapefile of Montevideo?

48 Views Asked by At

I would like to delimit my analysis to Montevideo City, capital of Uruguay.

How to subset this principal object, named uruguay?

Is there a link to Montevideo shapefile?

uruguay <- st_read("ine_seccen.shp")
tm_shape(uruguay) + tm_polygons()`

Uruguay, Latin America Uruguay

1

There are 1 best solutions below

0
On

Let's read in the data

uruguay <- sf::st_read("uruguay/ine_seccen.shp")
#> Reading layer `ine_seccen' from data source 
#>   `uruguay/ine_seccen.shp' using driver `ESRI Shapefile'
#> Simple feature collection with 232 features and 8 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 366582.2 ymin: 6127919 xmax: 858252.1 ymax: 6671738
#> Projected CRS: WGS 84 / UTM zone 21S

And let's check the data itself and plot it:

uruguay
#> Simple feature collection with 232 features and 8 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 366582.2 ymin: 6127919 xmax: 858252.1 ymax: 6671738
#> Projected CRS: WGS 84 / UTM zone 21S
#> First 10 features:
#>    ogc_fid        area perimeter depto seccion codsec  nombdepto cdepto_iso
#> 1        1    590829.7  3320.439     1       1    101 MONTEVIDEO       UYMO
#> 2        2    482430.9  4943.781     1       2    102 MONTEVIDEO       UYMO
#> 3        3    421108.0  3805.106     1       3    103 MONTEVIDEO       UYMO
#> 4        4    565182.3  3851.338     1       4    104 MONTEVIDEO       UYMO
#> 5        5    840787.2  4471.698     1       5    105 MONTEVIDEO       UYMO
#> 6        6    542797.2  3061.679     1       6    106 MONTEVIDEO       UYMO
#> 7        7   1222503.8  5869.490     1       7    107 MONTEVIDEO       UYMO
#> 8        8   2080318.8  6619.309     1       8    108 MONTEVIDEO       UYMO
#> 9        9 124589920.4 75168.524     1       9    109 MONTEVIDEO       UYMO
#> 10      10  27682916.7 31454.642     1      10    110 MONTEVIDEO       UYMO
#>                          geometry
#> 1  MULTIPOLYGON (((572996.2 61...
#> 2  MULTIPOLYGON (((572148.3 61...
#> 3  MULTIPOLYGON (((572708.3 61...
#> 4  MULTIPOLYGON (((573700.7 61...
#> 5  MULTIPOLYGON (((574375.3 61...
#> 6  MULTIPOLYGON (((574448.7 61...
#> 7  MULTIPOLYGON (((574382.2 61...
#> 8  MULTIPOLYGON (((574342.4 61...
#> 9  MULTIPOLYGON (((570567.2 61...
#> 10 MULTIPOLYGON (((578956.6 61...

tmap::tm_shape(uruguay) + 
  tmap::tm_polygons()

From the data snipet above we can see the nombdepto column contains names. Let's filter out only those polygons which are MONTEVIDEO boundaries.

mv <- uruguay |>
  subset(nombdepto == "MONTEVIDEO")

tmap::tm_shape(mv) + 
  tmap::tm_polygons()

Or, filter it directly in tm_shape() function providing a subset of our sf object:

tmap::tm_shape(uruguay[uruguay$nombdepto == "MONTEVIDEO", ]) +
  tmap::tm_polygons()

Created on 2023-12-27 with reprex v2.0.2

PS. In future / other question please either provide a representative data or link the original data file used. The ine_seccen.shp used in above examples were taken from https://visualizador.ide.uy/geonetwork/srv/api/records/c14e6a59-756c-44f1-bc4e-426e2573122b (Secciones Censales del Uruguay 2011 layer of WFS server).