![]() ![]() Hahaha, what a mess. But it'll work. I'm calculating a bounding box (with some margin for error) to retrieve the populations from the database double longitudeoffset = 0.1 GeoCoordinate Centre = new GeoCoordinate(latitude, longitude) Public class GlobalRingPopulationsController : ControllerBaseĭouble latitude = double.Parse(Request.Query) ĭouble longitude = double.Parse(Request.Query) ĭouble distance_km = double.Parse(Request.Query) So this is what my API looks like, using GeoCoordinatePortable I really like how you can start an ASP.NET project in Visual Studio, and deploy it to an Azure Web app, (and keep paying Microsoft for all that) really easily. Which is why I created it in DB Browser for SQLite. If you don't get this compound index right it'll take minutes instead of milliseconds to lookup the population at a point. Using (SQLiteConnection GridDB = new SQLiteConnection( "PopulationGrid.db")) Population = ( int) double.Parse(splitline) Latitude = Math.Round( double.Parse(splitline), 6), Longitude = Math.Round( double.Parse(splitline), 6), PopulationAtPoint pap = new PopulationAtPoint() Sr.ReadLine() // discard first line if it's X Y Z while (sr.EndOfStream = false) String XYSFilePath = sr = File.OpenText(XYSFilePath)) NET, and sqlite-net and it'll look something like this. Load your XYZ file into a SQLite database. GDAL.ĭownload GDAL and run something like gdal_translate -of XYZ GHS_POP_E2015_GLOBE_R2019A_4326_9ss_V1_0.tif 2015XYZ.xyz to create an XYZ file from the GHS geoTIFF. Here's some more details on the five points above, 1. I don't have time and you can probably do what you want in a few minutes anyway. I know you've thought of a few good ones. I set the minimum radius to 3km because otherwise some city-centre populations are likely to be very wrong and I can't be bothered fielding all the "your amateurish tool gives completely spurious information and you should be ashamed of yourself!" type comments that would generate. The maximum radius is set to 50km, it would get slow above that. I use this website to perform those queries and display the results.I create an API in C# ASP.NET running on an Azure Web App that does some geographical processing and queries the SQLite database to calculate the population within any distance of any location.I add a compound index (on latitude and longitude) to this SQLite database so that lookups are very fast. ![]()
0 Comments
Leave a Reply. |