11 votes
Accepted

Bash script for getting geolocation (latitude, longitude and country code)

Bugs: echo "$my_variable" | my_command can behave unexpectedly if the variable starts with one of the echo options. You can do <...
  • 8,747
10 votes

Converting Geographic Coordinates into Lambert2008 coordinates

Since the code is about implementing mathematical formulas I would make an exception and completely ignore the usual naming conventions. Instead, I would use the exact symbols as that document. This ...
  • 43.9k
8 votes
Accepted

Optimize web-scraping of Moscow grocery website

I want to focus principally on this section of your code: ...
  • 20.3k
8 votes
Accepted

Composing QGIS expression based on a QGIS layer tree

You do quite a lot or repetition. Using str.format you should be able to make your code smaller by using a comprehensions or map....
  • 41.7k
8 votes

Convert geodetic coordinates to geocentric (cartesian)

I can't explain the discrepancy with the online conversion tool without seeing the source code for the latter. 1. Review The comment for the ellipsoid parameters should give the units for the semi-...
  • 49.3k
8 votes
Accepted

Finding the nearest agents to a customer using IComparable

var agents = db.GetAgents(); if(agents == null || agents.Count == 0) { Console.WriteLine("No Results"); } You should exit your application/code block when you ...
  • 3,106
8 votes
Accepted

Converting Geographic Coordinates into Lambert2008 coordinates

public const double lowerLatitude = 49.8333333 * Mathf.Deg2Rad; Huh? Mathf.Deg2Rad is a ...
7 votes
Accepted

Latitude/longitude waypoint distance calculations, crosstrack, VMG, ETA, etc

It's not really clear why Odometer is a class. You only ever create one instance of it, and don't actually need any of the instance attributes. The only thing you ...
  • 13.8k
7 votes

Composing QGIS expression based on a QGIS layer tree

I'd like to approach this answer as a refactoring exercise. I'm going to iteratively improve your code little-by-little until the final result. 1. Remove unnecessary declarations and deletions The ...
  • 862
7 votes

Find my colleagues

In geoload.py use with..as to ensure it is closed, even if any code in-between raises an exception: ...
  • 40.6k
7 votes

Find my colleagues

You can simplify geoload by using the requests package. In fact it says this in the urllib documentation: See also: The Requests package is recommended for a ...
  • 41.7k
7 votes
Accepted

Where is the most desolate place in Colorado?

If this were a problem on the Euclidean plane, and not on the surface of the Earth, then it could be solved exactly by computing the Voronoi diagram for the set of airport locations, and intersecting ...
  • 49.3k
6 votes
Accepted

New Moon (not Twilight) Calculator

To accept user input for dates, DateTime::Format::Natural is a nice CPAN module to use. It spares you from having to input dates using the Unix epoch format and ...
6 votes

Python program to check if a set of points is at land or at sea

Style Your docstring at the top of the seq function should be moved underneath the function signature, like this: ...
6 votes
Accepted

Find my colleagues

One function per file? I know you can do better than that. Compare geoload.py with: ...
6 votes
Accepted

Calculating areas of map features

You can greatly simplify this code by introducing a helper function that calculates the area_score for one of the categories. Let's take the first category as an ...
  • 40.6k
6 votes
Accepted

Convert British and Irish National Grid references to or from WGS84 geodetic coordinates

NB: This review assumes Perl5, specifically the Unicode features in 5.12 (released 2010) and later. 1. the parsing could be simpler and more featureful Much code is devoted to handling delimiters ...
5 votes
Accepted

DbGeography search query

Instead of doing SELECT TOP 10 * FROM ... you should only retrieve the columns needed which in your case is LineName. ...
  • 50k
5 votes
Accepted

Compute spherical distance matrix from list of geographical coordinates

With numpy and its meshgrid functions, you don't have to do any looping at all, although under the hood looping similar to yours ...
  • 1,596
5 votes

Python program to check if a set of points is at land or at sea

Superficial issues """Function to iterate…""" is a docstring, which belongs inside the function definition, not before it. ...
5 votes

Composing QGIS expression based on a QGIS layer tree

I was writing a review along the lines of what @scottbb has suggested when I noticed that the formula that your code produces didn't make sense: ...
5 votes

Haversine Formula in Clojure

Naming and interface Please avoid mixing English (calculate-distance) with Portuguese (raio). The code should be in English; ...
5 votes

Mask latitude text field

Unless you know for sure that the degrees, minutes, and seconds are always going to be 2 digits each, this approach will cause issues. I would recommend using 3 separate inputs for each value and ...
5 votes

Convert geodetic coordinates to geocentric (cartesian)

Precision in numeric calculus is usually handled by the decimal module. Compare: ...
5 votes
Accepted

Work order spatial query (Part 1)

Functions are your friend Even in Jython, functions are a valid construct. They allow for scope, so that you can better reason about temporary variables; give better stack traces when things go wrong;...
  • 53.3k
5 votes
Accepted

Parsing Addresses with GeoPanda's GeoDataFrame

Nomenclature Function names should be snake_case per PEP8, i.e. address_parsing. Type hinting For function parameters and return values mainly, type hinting will ...
  • 53.3k
4 votes
Accepted

Downloading 2 tables from db, does calculation and uploads resulting table

I know, that you know, that your code is messy, but I'm still going to give some tips on your coding style. Here are a few tips I have on what can be improved there. Don't use ...
4 votes
Accepted

Finding travel distance between airports

First, let's download some data similar to yours (I assume). This csv available online has almost 7,000 airports: ...
  • 3,445
4 votes
Accepted

Clustering 16 million records in parallel

Hard to tell without sample data, but lets start with a cleaned up version as there's soo much duplicated code here and the formatting is inconsistent. The require ...
  • 11k
4 votes
Accepted

Arcpy script to check for TIFF files and add them to different lists

You want to learn what a dictionary is, and store your rasters in it. With Python this is pretty simple, to make a dictionary that when you ask for an apple gives you a 'red apple' you could do: <...
  • 41.7k

Only top scored, non community-wiki answers of a minimum length are eligible