Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
Directly reading data from netCDF files in a django view vs. inserting data from the NetCDF into a database + querying the data in the view?

For a django application, I need to process multiple netCDF files each day. Each file contains a 3-dimensional data array (latitude, longitude, time) of one variable with with a shape of (1000, 1000, 24).

In some views of the django application I want to access specific values of these data arrays, i.e. the time series on a specific location (given the latitude and longitude) or the entire map of a variable at a specific point in time.

In data science projects, I typically do this by opening the file with xarray (xarray.open_dataset('file.nc')) and using xarray's .sel() to select the desired values.

In the django application, I currently store the variables in a model that looks like the following:

class Geoid(models.model):
    latitude = models.FloatField()
    longitude = models.FloatField()

class Timestamp(models.model):
    time = models.DateTimeField()

class Variable(models.model):
    geoid = models.ForgeinKey(Geoid)
    time = models.ForgeinKey(Timestamp)
    value = models.FloatField()

I realized that inserting the 1000x1000x24 = 24,000,000 data points of each file into the database takes too much time even if I use django's .bulk_create() method.

This led me to my questions:

Would it actually be better to directly read the data in a django view from the netCDF files using xarray? What would be the pros and cons?

I looked into GeoDjango and the available RasterField but I could not find a method how to lookup pixel values (i.e. given the latitude and the longitude) of a RasterField in a fast and clean way.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!