First we read csv file, that has the list of Colombian cities and their coordinates respectively
## city lat lng country iso2 admin_name capital
## 1 Bogotá 4.6126 -74.0705 Colombia CO Bogotá primary
## 2 Medellín 6.2447 -75.5748 Colombia CO Antioquia admin
## 3 Cali 3.4400 -76.5197 Colombia CO Valle del Cauca admin
## 4 Barranquilla 10.9639 -74.7964 Colombia CO Atlántico admin
## 5 Cartagena 10.4236 -75.5253 Colombia CO Bolívar admin
## 6 Soacha 4.5781 -74.2144 Colombia CO Cundinamarca minor
## population population_proper
## 1 9464000 7963000
## 2 2529403 2529403
## 3 2471474 2471474
## 4 1274250 1274250
## 5 1036412 1036412
## 6 995268 995268
With the pacakge ggplo2
we can do a scatter-plot of the cities.
read the csv file as simple feature object with sf
package
## [1] "cities.cpg" "cities.dbf" "cities.prj"
## [4] "cities.shp" "cities.shx" "ciudades.gpkg"
## [7] "Clase1_071021.html" "clase1_071021.qgz" "Clase1_071021.Rmd"
## [10] "Clase1_071021_files" "co.csv" "rsconnect"
## [13] "screenshots"
## Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
## options: X_POSSIBLE_NAMES=lng Y_POSSIBLE_NAMES=lat
## Reading layer `co' from data source `C:\Users\ADMIN\Documentos\CARLOS\UNAL\Asignaturas\Geomatica\Clase 1\co.csv' using driver `CSV'
## Simple feature collection with 1102 features and 9 fields
## geometry type: POINT
## dimension: XY
## bbox: xmin: -81.7006 ymin: -4.215 xmax: -67.4858 ymax: 13.3817
## CRS: NA
## Simple feature collection with 1102 features and 9 fields
## geometry type: POINT
## dimension: XY
## bbox: xmin: -81.7006 ymin: -4.215 xmax: -67.4858 ymax: 13.3817
## CRS: NA
## First 10 features:
## city lat lng country iso2 admin_name capital
## 1 Bogotá 4.6126 -74.0705 Colombia CO Bogotá primary
## 2 Medellín 6.2447 -75.5748 Colombia CO Antioquia admin
## 3 Cali 3.4400 -76.5197 Colombia CO Valle del Cauca admin
## 4 Barranquilla 10.9639 -74.7964 Colombia CO Atlántico admin
## 5 Cartagena 10.4236 -75.5253 Colombia CO Bolívar admin
## 6 Soacha 4.5781 -74.2144 Colombia CO Cundinamarca minor
## 7 Palermo 2.8883 -75.4339 Colombia CO Huila minor
## 8 Cúcuta 7.9075 -72.5047 Colombia CO Norte de Santander admin
## 9 Soledad 10.9200 -74.7700 Colombia CO Atlántico minor
## 10 Pereira 4.8143 -75.6946 Colombia CO Risaralda admin
## population population_proper geometry
## 1 9464000 7963000 POINT (-74.0705 4.6126)
## 2 2529403 2529403 POINT (-75.5748 6.2447)
## 3 2471474 2471474 POINT (-76.5197 3.44)
## 4 1274250 1274250 POINT (-74.7964 10.9639)
## 5 1036412 1036412 POINT (-75.5253 10.4236)
## 6 995268 995268 POINT (-74.2144 4.5781)
## 7 800000 800000 POINT (-75.4339 2.8883)
## 8 750000 750000 POINT (-72.5047 7.9075)
## 9 698852 342556 POINT (-74.77 10.92)
## 10 590554 590554 POINT (-75.6946 4.8143)
cities
cities['admin_name']
mapview
package