You can tell where the city ends very easily. There are well-defined boundaries. Government statistics take that into account. Here's the census page for the city of Los Angeles, which lists a population just under 4 million: https://data.census.gov/profile/Los_Angeles_city,_California...