0

I have a table summarising a balance for 15 different zipcodes, it has latitude and longitude. 4 columns in total: zipcode, balance (integer), latitude, and longitude.

Here it is:

Table

Latitude and longitude were mapped from the main USA zipcodes database.

I want to reflect the balance of each zip code on the map, but it is not showing it.

Here is the code:

ggmap(map) + geom_point(data = eigpm_sp_summ2, aes(lat, lng,
                         size=mean_b)) +
  scale_color_gradient(low="black", high="blue")

Here is the map it is showing me:

Map

Any idea what I'm doing wrong?

Humberto R
  • 19
  • 4
  • Does this answer your question? [Plotting static base map underneath a sf object](https://stackoverflow.com/questions/49626233/plotting-static-base-map-underneath-a-sf-object) – Captain Hat Jun 07 '23 at 09:48

1 Answers1

0

You can add a geom_sf layer to your code

ggmap(map) + geom_point(data = eigpm_sp_summ2, aes(lat, lng,
                         size=mean_b)) +
  geom_sf(mapping = aes(fill = zip)) + 
  scale_color_gradient(low="black", high="blue")
Abdullah Faqih
  • 116
  • 1
  • 7
  • Thanks @abdullah-faqih is still giing tis error _Coordinate system already present. Adding new coordinate system, which will replace the existing one. Error in `geom_sf()`: ! Problem while computing aesthetics. ℹ Error occurred in the 5th layer. Caused by error in `FUN()`: ! object 'zip_code' not found_ Any ideas? – Humberto R Jun 10 '23 at 02:33