0

I am trying to create a heatmap with real estate objects, which shows where the objects with low and where the objects with high prices are located. However, the current heatmap only shows where the density of objects in general is the highest / lowest.

Thanks a lot!

Best, Nicole

ggmap(London) + 
  stat_density2d(aes(x = listing.longitude, 
                     y = listing.latitude, 
                     fill = ..level.., 
                     alpha = ..level..),
                 size = 2, 
                 bins = 4, 
                 data = Properties_forsale, 
                 geom = "polygon") + 
  scale_fill_gradient(low = "green", 
                      high = "red") + 
  geom_tile(data = Properties_forsale, 
            aes(x = listing.longitude, 
                y = listing.latitude, 
                col = listing.price, 
                alpha = 0.5)
            )
slamballais
  • 3,161
  • 3
  • 18
  • 29
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. It's unclear exactly what you are trying to achieve. A density plot typically only shows the observations mass. It's not clear how you would reinterpret that to represent high/low prices. Maybe you just want 2D binned means? – MrFlick May 16 '21 at 05:49
  • My datasets shoes 5000 different properties, their longitude and latitude and their price. I now want to show on the map in which area the prices are the highest / lowest with a heatmap. Thanks! – Nicole Brühwiler May 16 '21 at 10:53

0 Answers0